<!DOCTYPE html>
<html lang="en" dir="auto">

<head><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="robots" content="index, follow">
<title>yolov5原理与源码 | flipped</title>
<meta name="keywords" content="Yolo, Python, Object Detection" />
<meta name="description" content="Guide for yolov5">
<meta name="author" content="flipped">
<link rel="canonical" href="http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%8E%9F%E7%90%86%E4%B8%8E%E6%BA%90%E7%A0%81/" />
<link crossorigin="anonymous" href="/flippedzh/assets/css/stylesheet.min.2d6dbfc6e0f8a1db1c9d082a76dc11d094328cf63f247bbc2421dfaa7f2bb170.css" integrity="sha256-LW2/xuD4odscnQgqdtwR0JQyjPY/JHu8JCHfqn8rsXA=" rel="preload stylesheet" as="style">
<script defer crossorigin="anonymous" src="/flippedzh/assets/js/highlight.min.7680afc38aa6b15ddf158a4f3780b7b1f7dde7e91d26f073e6229bb7a0793c92.js" integrity="sha256-doCvw4qmsV3fFYpPN4C3sffd5&#43;kdJvBz5iKbt6B5PJI="
    onload="hljs.initHighlightingOnLoad();"></script>
<link rel="icon" href="http://zouheng22.gitee.io/flippedzh/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="http://zouheng22.gitee.io/flippedzh/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="http://zouheng22.gitee.io/flippedzh/favicon-32x32.png">
<link rel="apple-touch-icon" href="http://zouheng22.gitee.io/flippedzh/apple-touch-icon.png">
<link rel="mask-icon" href="http://zouheng22.gitee.io/flippedzh/safari-pinned-tab.svg">
<meta name="theme-color" content="#2e2e33">
<meta name="msapplication-TileColor" content="#2e2e33">
<meta name="generator" content="Hugo 0.83.1" />
<link rel="alternate" hreflang="en" href="http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%8E%9F%E7%90%86%E4%B8%8E%E6%BA%90%E7%A0%81/" />
<meta property="og:title" content="yolov5原理与源码" />
<meta property="og:description" content="Guide for yolov5" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%8E%9F%E7%90%86%E4%B8%8E%E6%BA%90%E7%A0%81/" /><meta property="og:image" content="http://zouheng22.gitee.io/flippedzh/papermod-cover.png"/><meta property="article:section" content="posts" />




<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="http://zouheng22.gitee.io/flippedzh/papermod-cover.png"/>

<meta name="twitter:title" content="yolov5原理与源码"/>
<meta name="twitter:description" content="Guide for yolov5"/>


<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [, 
    {
      "@type": "ListItem",
      "position":  2 ,
      "name": "Posts",
      "item": "http://zouheng22.gitee.io/flippedzh/posts/"
    }, 
    {
      "@type": "ListItem",
      "position":  3 ,
      "name": "yolov5原理与源码",
      "item": "http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%8E%9F%E7%90%86%E4%B8%8E%E6%BA%90%E7%A0%81/"
    }
  ]
}
</script>
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "headline": "yolov5原理与源码",
  "name": "yolov5原理与源码",
  "description": "Guide for yolov5",
  "keywords": [
    "Yolo", "Python", "Object Detection"
  ],
  "articleBody": "  资源：\n源码注释：\n 参考1 参考2    预备知识\n  detector=backbone + neck + head ,常见的目标检测网络结构\n  目标检测发展：古典(ss+svm)-RCNN(先找候选框(类似图像聚类的算法))- SPPNET-FastRCNN(ss+RCNN)-FasterRCNN(RPN(粗分类)+FastRCNN),都是两阶段的算法\n  参考\n  目标检测中的评价指标(以围棋棋子检测为例)：\n P：准确率/精确率：\n检出100个检测框中有90个是对的：P:90% AP 代表Average Precision，即平均精确度 。\n针对黑子100个检测结果中有100个是对的：P:100% 针对白子100个检测结果中有80个是对的：P:80% AP：90% Recall:召回率：\n实际100颗黑子 ，检出80颗黑子，R：80%\tRecall与P本质是分母的不同 mAP: Mean Average Precision的缩写，即均值平均精度\nmAP = 所有类别的平均精度求和除以所有类别。 交并比\n一般可以通过移除一些IOU值大于某个阈值的框来完成非极大值抑制(设置iou=0,表示检测出的结果框不会重叠)    backbone\nResNet (ResNet18, 50, 100)\rResNext\rDenseNet\rSqueezeNet\rDarknet (Darknet19,53)\rMobileNet\rShuffleNet\rDetNet\rDetNAS\rSpineNet\rEfficientNet (EfficientNet-BO/B7)\rCSPResNeXt50\rCSPDarknet53\r  neck\nAdditional blocks:\rSPP\rASPP\rRFB\rSAM\rPath-aggregation blocks:\rFPN\rPAN\rNAS-FPN\rFully-connected FPN\rBiFPN\rASFF\rSFAM\rNAS-FPN   head\nDense Prediction (one-stage):\rRPN\rSSD\rYOLO\rRetinaNet\r(anchor based)\rCornerNet\rCenterNet\rMatrixNet\rFCOS(anchor free)\rSparse Prediction (two-stage):\rFaster R-CNN\rR-FCN\rMask RCNN (anchor based)\rRepPoints(anchor free)\r    yolov1\n onestage: 将对象概率、两个boundingBox的置信度、boundingBox的位置信息放在一个张量中 (通过不同的通道) yolov1网络结构  详解： 参考\n问题：\n为什么要两个bbox？\n怎么确定这两个bbox？（一个大的一个小的，通过iou结合ground truth进行判断） :中心点必须在grid中 bbox的置信度怎么计算 ？ 一个grid单元最多预测一个物体，所以一张图最多预测49个物体 yolo损失函数约定了候选框与gt之间的关系，中间是不是应该还有候选框的修正？ 训练的过程留下的结果怎么通过网络参数进行体现？  怎么保证对象的框一定能将对象刚好包起来 因为想 x，y也是超参数（也在损失函数里面），也会随着训练的过程，靠近groundtruth\nnms只作用在预测阶段\n  yolov1的局限性：\n一张图中最多只能识别7*7=49个目标\n  训练阶段 针对一个gridcell，首先每个girdcell的20个类别的概率乘以每个boundingbox的执行度，每个boundingbox可以得到20个全概率，那么由此可以确定该gridcell的代表类别。 根据这个代表类别的groundtruth与两个框的IOU来确定到底由哪个boundingbox去拟合boundboxing。 如果girdcell没有落在所属于的类别中，那么这两个框都不用拟合，淘汰\n  损失函数\n 第一项：中心点的定位误差（预测值与标注值） 第二项：负责检测物体的宽高定位误差（boundingBox与groundtruth尽量拟合） 第三项： 负责检测类别的boundingbox的置信度误差 第四项： 不负责检测类别的boundingbox的置信度误差 第五项： 负责检测类别的boundingbox的分类误差    什么是置信度误差？\n  参考\n  yolov1论文精读\n     网络结构\n Backbone  CSPDarknet53 with Mish activation(激活) 负责从图像中提取特征   neck  模块采用的是PANet和增强模块SPP。SPP结构非常容易理解，就是不同kernel size的pool操作进行融合，在yolov3的改进版中也有应用，对整个运行速度影响很小，但是效果提升明显。而PANet是FPN结构的改进版本，目的是加快信息之间的流通，具体细节可以参考想读懂YOLOV4 neck是放在backbone和head之间的，是为了更好的利用backbone提取的特征。   head  这一部分的作用就是用于分类+定位。      vgg详解\n  经典神经网络结构\n 演示 搭建简单的神经网络：  import torch\rimport torch.nn as nn\rimport torch.nn.functional as F\rimport matplotlib.pyplot as plt\rfrom torch.autograd import Variable\rx = torch.unsqueeze(torch.linspace(-1,1,100),dim=1)\ry = x.pow(3)+0.1*torch.randn(x.size())\r## (1*100)的张量\rx , y =(Variable(x),Variable(y))\rplt.scatter(x,y)\rplt.scatter(x.data,y.data)\rplt.scatter(x.data.numpy(),y.data.numpy())\rplt.show()\r## 创建网络结构的模板\rclass Net(nn.Module):\r## 中间层与输出层的神经元数\rdef __init__(self,n_input,n_hidden,n_output):\rsuper(Net,self).__init__()\r##两个隐藏层\rself.hidden1 = nn.Linear(n_input,n_hidden)\rself.hidden2 = nn.Linear(n_hidden,n_hidden)\r##输出层\rself.predict = nn.Linear(n_hidden,n_output)\r##必须定义的函数==定义激活函数\rdef forward(self,input):\rout = self.hidden1(input)\rout = F.relu(out)\rout = self.hidden2(out)\rout = F.sigmoid(out)\rout =self.predict(out)\rreturn out\rnet = Net(1,20,1)\rprint(net)\r## 优化器\roptimizer = torch.optim.SGD(net.parameters(),lr = 0.1)\r## 定义损失函数==均方损失函数==适用于回归问题\rloss_func = torch.nn.MSELoss()\rplt.ion()\rplt.show()\r## 跌代计算5000次\rfor t in range(5000):\r## 计算损失值\rprediction = net(x)\rloss = loss_func(prediction,y)\r## 梯度初始化为0 =不清零的话 梯度会默认累加，上次的结果会影响本次计算\roptimizer.zero_grad()\r## 反向传播\rloss.backward()\r## 优化梯度\roptimizer.step()\rif t%5 ==0:\rplt.cla()\rplt.scatter(x.data.numpy(), y.data.numpy())\rplt.plot(x.data.numpy(), prediction.data.numpy(), 'r-', lw=5)\rplt.text(0.5, 0, 'Loss = %.4f' % loss.data, fontdict={'size': 20, 'color': 'red'})\rplt.pause(0.05)\rplt.ioff()\rplt.show()\r解答：PyTorch中在反向传播前为什么要手动将梯度清零\n关键字：\n隐藏层(除输入层和输出层以外的其他各层叫做隐藏层)=卷积层（Convolution）/\r激活层（Activation）/\r池化层（Pooling）/\r完全连接层(Fully connected)\r全连接层\r损失函数：均方损失函数\r梯度\rloss\r优化器\r反向传播\r学习率\r激活函数：relu sigmod\r超参数\r张量\r全连接层的意义 多层全连接层的意义\n激活函数的意义\n权重参数只在全连接层？ 反向传播：真实值与预测值求误差？==更新卷积核参数(反馈)\n超参数就是初始参数：卷积核的大小、数目、池化的步长、全连接 层的神经元数\n全连接层 神经元数目的区别\n神经网络的含义就是全连接层的神经元\n激活函数与输出函数的区别是什么?\n反向传播与梯度下降的关系 ？ 正向传播：\n反向传播：就是在求损失函数对某一权重的偏导数(递增或递减的关系)，这样就可以知道应该怎么去调整权重的值。\n反向输入为误差的求导值(损失函数的求导值)\n更新权值的过程=求梯度(链式法则)+梯度下降\n视频讲解1(推荐)\n视频讲解2\n梯度下降：推所有，拉一个 梯度下降就是通过数值法求导数然后更新x值的过程,在网络中的作用就是更新权重。\n学习率就是权重更新时候的学习率\n其他问题：\n为什么要用反向传播算法？\n激活函数：softmax\n一般只作输出层的激活函数 softmax函数一般与交叉熵函损失函数同时实现 激活函数的作用：激活函数可以让神经网络具有非线性拟合的能力\n激活函数既可以用在隐藏层(relu/tanh/sigmod)，也可以用在输出层(softmax/等值/sigmod)\nsigmod可以将任意输入映射至(0,1)\n激活函数的作用是：增加模型的非线性表达能力\n损失函数:\n  MSE: 最小均方差\n  CE： 交叉熵\n  使用softmax实现分类\n//TODO\r  张量(tensor)(一种数据结构)\n标量– 0阶张量\n向量– 1阶张量\n矩阵– 2阶张量\n     pytorch的使用\n  https://www.cnblogs.com/sdu20112013/p/12101172.html\n按分类的效果来说呢，隐藏层的单元数是越多越好的，但是过多的神经元会让训练相当的缓慢，因此需要平衡一下，一般将隐藏层的单元数设置为输入层单元数的2~4倍为宜。而隐藏层的层数呢就以1、2、3层比较常见。\n多个全连接层+激活层 的作用 类似泰勒级数\nPytorch的交叉熵nn.CrossEntropyLoss在训练阶段，里面是内置了softmax操作的，因此只需要喂入原始的数据结果即可，不需要在之前再添加softmax层。\n首先softmax不是损失函数,而是进行多分类时使用的激活函数。\n学习率设置过大可能会导致，损失函数的值在极值点的附近震荡而不收敛。\n激活函数：https://zhuanlan.zhihu.com/p/72462178\nsoftmax层只是对神经网络的输出结果进行了一次换算，将输出结果用概率的形式表现出来。\n如果要使用softmax 是不是不用在 网络层中显示添加？ https://zhuanlan.zhihu.com/p/105722023 再看一遍\nsigmod 与 softmax:\n简单点理解就是，Sigmoid函数，我们可以当作成它是对一个类别的“建模”，将该类别建模完成，另一个相对的类别就直接通过1减去得到。而softmax函数，是对两个类别建模，同样的，得到两个类别的概率之和是1。\nsoftmax激活函数：\n交叉熵损失函数： ",
  "wordCount" : "382",
  "inLanguage": "en",
  "datePublished": "0001-01-01T00:00:00Z",
  "dateModified": "0001-01-01T00:00:00Z",
  "author":{
    "@type": "Person",
    "name": "flipped"
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%8E%9F%E7%90%86%E4%B8%8E%E6%BA%90%E7%A0%81/"
  },
  "publisher": {
    "@type": "Organization",
    "name": "flipped",
    "logo": {
      "@type": "ImageObject",
      "url": "http://zouheng22.gitee.io/flippedzh/favicon.ico"
    }
  }
}
</script>
</head>

<body class="" id="top">
<script>
    if (localStorage.getItem("pref-theme") === "dark") {
        document.body.classList.add('dark');
    } else if (localStorage.getItem("pref-theme") === "light") {
        document.body.classList.remove('dark')
    } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
        document.body.classList.add('dark');
    }

</script>
<noscript>
    <style type="text/css">
        #theme-toggle,
        .top-link {
            display: none;
        }

    </style>
    <style>
        @media (prefers-color-scheme: dark) {
            :root {
                --theme: #1d1e20;
                --entry: #2e2e33;
                --primary: rgba(255, 255, 255, 0.84);
                --secondary: rgba(255, 255, 255, 0.56);
                --tertiary: rgba(255, 255, 255, 0.16);
                --content: rgba(255, 255, 255, 0.74);
                --hljs-bg: #2e2e33;
                --code-bg: #37383e;
                --border: #333;
            }

            .list {
                background: var(--theme);
            }

            .list:not(.dark)::-webkit-scrollbar-track {
                background: 0 0;
            }

            .list:not(.dark)::-webkit-scrollbar-thumb {
                border-color: var(--theme);
            }
        }

    </style>
</noscript>

<header class="header">
    <nav class="nav">
        <div class="logo">
            <a href="http://zouheng22.gitee.io/flippedzh" accesskey="h" title="flipped (Alt + H)">flipped</a>
            <span class="logo-switches">
                <button id="theme-toggle" accesskey="t" title="(Alt + T)">
                    <svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
                        fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                        stroke-linejoin="round">
                        <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
                    </svg>
                    <svg id="sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
                        fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                        stroke-linejoin="round">
                        <circle cx="12" cy="12" r="5"></circle>
                        <line x1="12" y1="1" x2="12" y2="3"></line>
                        <line x1="12" y1="21" x2="12" y2="23"></line>
                        <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
                        <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
                        <line x1="1" y1="12" x2="3" y2="12"></line>
                        <line x1="21" y1="12" x2="23" y2="12"></line>
                        <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
                        <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
                    </svg>
                </button>
                
            </span>
        </div>
        <ul id="menu">
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/archives/" title="文章">
                    <span>文章</span>
                </a>
            </li>
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/categories" title="目录">
                    <span>目录</span>
                </a>
            </li>
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/tags" title="标签">
                    <span>标签</span>
                </a>
            </li>
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/series" title="系列">
                    <span>系列</span>
                </a>
            </li>
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/search/" title="搜索">
                    <span>搜索</span>
                </a>
            </li>
            <li>
                <a href="http://zouheng22.gitee.io/flippedzh/fr" title="关于我">
                    <span>关于我</span>
                </a>
            </li>
        </ul>
    </nav>
</header>
<main class="main">

<article class="post-single">
  <header class="post-header">
    <div class="breadcrumbs"><a href="http://zouheng22.gitee.io/flippedzh">Home</a>&nbsp;»&nbsp;<a href="http://zouheng22.gitee.io/flippedzh/posts/">Posts</a></div>
    <h1 class="post-title">
      yolov5原理与源码
    </h1>
    <div class="post-description">
      Guide for yolov5
    </div>
    <div class="post-meta">2 min&nbsp;·&nbsp;flipped
</div>
  </header> <div class="toc">
    <details  open>
        <summary accesskey="c" title="(Alt + C)">
            <div class="details">Table of Contents</div>
        </summary>
        <div class="inner">
        </div>
    </details>
</div>

  <div class="post-content"><ol>
<li>
<p>资源：<br>
源码注释：</p>
<ul>
<li><a href="https://github.com/hhaAndroid/yolov5-comment">参考1</a></li>
<li><a href="https://zhuanlan.zhihu.com/p/172121380">参考2</a></li>
</ul>
</li>
<li>
<p>预备知识</p>
<ul>
<li>
<p>detector=backbone + neck + head ,常见的目标检测网络结构</p>
</li>
<li>
<p>目标检测发展：古典(ss+svm)-&gt;RCNN(先找候选框(类似图像聚类的算法))-&gt; SPPNET-&gt;FastRCNN(ss+RCNN)-&gt;FasterRCNN(RPN(粗分类)+FastRCNN),都是两阶段的算法</p>
</li>
<li>
<p><a href="https://blog.csdn.net/weixin_48780159/article/details/115573361">参考</a></p>
</li>
<li>
<p>目标检测中的评价指标(以围棋棋子检测为例)：</p>
<ul>
<li><strong>P</strong>：准确率/精确率：<br>
检出100个检测框中有90个是对的：P:90%</li>
<li><strong>AP</strong> 代表Average Precision，即平均精确度 。<br>
针对黑子100个检测结果中有100个是对的：P:100%
针对白子100个检测结果中有80个是对的：P:80%
AP：90%</li>
<li><strong>Recall</strong>:召回率：<br>
实际100颗黑子 ，检出80颗黑子，R：80%	
Recall与P本质是分母的不同</li>
<li><strong>mAP</strong>: Mean Average Precision的缩写，即均值平均精度<br>
mAP = 所有类别的平均精度求和除以所有类别。</li>
<li><strong>交并比</strong><br>
<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbytecat.net%2Fupload_images%2F20200306021618.jpg&refer=http%3A%2F%2Fbytecat.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641374757&t=bc9e20f953f7fc2c2d223a5b83b6ae66" height=40% width=40%><br>
一般可以通过移除一些IOU值大于某个阈值的框来完成非极大值抑制(设置iou=0,表示检测出的结果框不会重叠)</li>
</ul>
</li>
<li>
<p>backbone</p>
<pre><code>ResNet (ResNet18, 50, 100)
ResNext
DenseNet
SqueezeNet
Darknet (Darknet19,53)
MobileNet
ShuffleNet
DetNet
DetNAS
SpineNet
EfficientNet (EfficientNet-BO/B7)
CSPResNeXt50
CSPDarknet53
</code></pre></li>
<li>
<p>neck</p>
<pre><code>Additional blocks:
SPP
ASPP
RFB
SAM
Path-aggregation blocks:
FPN
PAN
NAS-FPN
Fully-connected FPN
BiFPN
ASFF
SFAM
NAS-FPN    
</code></pre></li>
<li>
<p>head</p>
<pre><code>Dense Prediction (one-stage):
RPN
SSD
YOLO
RetinaNet
(anchor based)
CornerNet
CenterNet
MatrixNet
FCOS(anchor free)
Sparse Prediction (two-stage):
Faster R-CNN
R-FCN
Mask RCNN (anchor based)
RepPoints(anchor free)
</code></pre></li>
</ul>
</li>
<li>
<p>yolov1</p>
<ul>
<li>onestage: 将对象概率、两个boundingBox的置信度、boundingBox的位置信息放在一个张量中 (通过不同的通道)
yolov1网络结构
<img loading="lazy" src="https://pic2.zhimg.com/v2-970ca183f3f0c76591c82ca910d2bc5d_r.jpg" alt="网络结构"  />
</li>
<li>详解：  <a href="https://www.bilibili.com/video/BV15w411Z7LG?p=7&amp;spm_id_from=pageDriver">参考</a><br>
问题：<br>
为什么要两个bbox？<br>
怎么确定这两个bbox？（一个大的一个小的，通过iou结合ground truth进行判断）
:中心点必须在grid中
bbox的置信度怎么计算 ？
一个grid单元最多预测一个物体，所以一张图最多预测49个物体
yolo损失函数约定了候选框与gt之间的关系，中间是不是应该还有候选框的修正？
训练的过程留下的结果怎么通过网络参数进行体现？</li>
</ul>
<p><strong>怎么保证对象的框一定能将对象刚好包起来</strong>
因为想 x，y也是超参数（也在损失函数里面），也会随着训练的过程，靠近groundtruth</p>
<p>nms只作用在预测阶段</p>
<ul>
<li>
<p>yolov1的局限性：<br>
一张图中最多只能识别7*7=49个目标</p>
</li>
<li>
<p><strong>训练阶段</strong>
针对一个gridcell，首先每个girdcell的20个类别的概率乘以每个boundingbox的执行度，每个boundingbox可以得到20个全概率，那么由此可以确定该gridcell的代表类别。
根据这个代表类别的groundtruth与两个框的IOU来确定到底由哪个boundingbox去拟合boundboxing。
如果girdcell没有落在所属于的类别中，那么这两个框都不用拟合，淘汰</p>
</li>
<li>
<p>损失函数</p>
<ul>
<li>第一项：中心点的定位误差（预测值与标注值）</li>
<li>第二项：负责检测物体的宽高定位误差（boundingBox与groundtruth尽量拟合）</li>
<li>第三项： 负责检测类别的boundingbox的置信度误差</li>
<li>第四项： 不负责检测类别的boundingbox的置信度误差</li>
<li>第五项： 负责检测类别的boundingbox的分类误差</li>
</ul>
</li>
<li>
<p>什么是置信度误差？</p>
</li>
</ul>
<p><a href="https://www.bilibili.com/video/BV15w411Z7LG?p=6&amp;spm_id_from=pageDriver">参考</a></p>
</li>
<li>
<p>yolov1论文精读</p>
<ul>
<li></li>
</ul>
</li>
<li>
<p>网络结构</p>
<ul>
<li>Backbone
<ul>
<li><strong>CSPDarknet53</strong> with Mish activation(激活)</li>
<li>负责从图像中提取特征</li>
</ul>
</li>
<li>neck
<ul>
<li>模块采用的是PANet和增强模块SPP。SPP结构非常容易理解，就是不同kernel size的pool操作进行融合，在yolov3的改进版中也有应用，对整个运行速度影响很小，但是效果提升明显。而PANet是FPN结构的改进版本，目的是加快信息之间的流通，具体细节可以参考想读懂YOLOV4</li>
<li>neck是放在backbone和head之间的，是为了更好的利用backbone提取的特征。</li>
</ul>
</li>
<li>head
<ul>
<li>这一部分的作用就是用于分类+定位。</li>
</ul>
</li>
</ul>
</li>
<li>
<p><a href="https://www.bilibili.com/video/BV1fU4y1E7bY?from=search&amp;seid=1477969294684245493&amp;spm_id_from=333.337.0.0">vgg详解</a></p>
<ul>
<li>
<p><a href="https://www.bilibili.com/video/BV1K7411W7So?p=11">经典神经网络结构</a></p>
<ul>
<li><a href="https://www.cs.ryerson.ca/~aharley/vis/conv/">演示</a></li>
<li><a href="https://zhuanlan.zhihu.com/p/114980874"> 搭建简单的神经网络</a>：</li>
</ul>
<pre><code>import torch
import torch.nn as nn
import torch.nn.functional as F
import matplotlib.pyplot as plt
from torch.autograd import Variable

x = torch.unsqueeze(torch.linspace(-1,1,100),dim=1)
y = x.pow(3)+0.1*torch.randn(x.size())

## (1*100)的张量
x , y =(Variable(x),Variable(y))

plt.scatter(x,y)
plt.scatter(x.data,y.data)
plt.scatter(x.data.numpy(),y.data.numpy())
plt.show()

## 创建网络结构的模板
class Net(nn.Module):
                    ## 中间层与输出层的神经元数
    def __init__(self,n_input,n_hidden,n_output):
        super(Net,self).__init__()
        ##两个隐藏层
        self.hidden1 = nn.Linear(n_input,n_hidden)
        self.hidden2 = nn.Linear(n_hidden,n_hidden)
        ##输出层
        self.predict = nn.Linear(n_hidden,n_output)
    ##必须定义的函数==定义激活函数
    def forward(self,input):
        out = self.hidden1(input)
        out = F.relu(out)
        out = self.hidden2(out)
        out = F.sigmoid(out)
        out =self.predict(out)
        return out

net = Net(1,20,1)
print(net)

## 优化器
optimizer = torch.optim.SGD(net.parameters(),lr = 0.1)
## 定义损失函数==均方损失函数==适用于回归问题
loss_func = torch.nn.MSELoss()

plt.ion()
plt.show()

## 跌代计算5000次
for t in range(5000):
    ## 计算损失值
    prediction = net(x)
    loss = loss_func(prediction,y)

    ## 梯度初始化为0  =不清零的话 梯度会默认累加，上次的结果会影响本次计算
    optimizer.zero_grad()
    ## 反向传播
    loss.backward()

    ## 优化梯度
    optimizer.step()

    if t%5 ==0:
        plt.cla()
        plt.scatter(x.data.numpy(), y.data.numpy())
        plt.plot(x.data.numpy(), prediction.data.numpy(), 'r-', lw=5)
        plt.text(0.5, 0, 'Loss = %.4f' % loss.data, fontdict={'size': 20, 'color': 'red'})
        plt.pause(0.05)

plt.ioff()
plt.show()
</code></pre><p>解答：<a href="https://www.zhihu.com/question/303070254">PyTorch中在反向传播前为什么要手动将梯度清零</a></p>
<p>关键字：</p>
<pre><code>隐藏层(除输入层和输出层以外的其他各层叫做隐藏层)=卷积层（Convolution）/
        激活层（Activation）/
        池化层（Pooling）/
        完全连接层(Fully connected)
全连接层
损失函数：均方损失函数
梯度
loss
优化器
反向传播
学习率
激活函数：relu sigmod
超参数
张量
</code></pre><p>全连接层的意义
多层全连接层的意义<br>
<a href="https://zhuanlan.zhihu.com/p/104318223">激活函数</a>的意义<br>
权重参数只在全连接层？
反向传播：真实值与预测值求误差？==更新卷积核参数(反馈)<br>
超参数就是初始参数：卷积核的大小、数目、池化的步长、全连接  层的神经元数</p>
<p>全连接层 神经元数目的区别</p>
<p>神经网络的含义就是全连接层的神经元</p>
<p>激活函数与输出函数的区别是什么?</p>
<p>反向传播与梯度下降的关系 ？
正向传播：<br>
反向传播：就是在求损失函数对某一权重的偏导数(递增或递减的关系)，这样就可以知道应该怎么去调整权重的值。<br>
反向输入为误差的求导值(损失函数的求导值)<br>
更新权值的过程=<a href="%E6%B1%82%E6%A2%AF%E5%BA%A6(%E9%93%BE%E5%BC%8F%E6%B3%95%E5%88%99)+%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D">求梯度(链式法则)+梯度下降</a><br>
<a href="https://www.bilibili.com/video/BV14q4y1V7bc?from=search&amp;seid=11260775118897267894&amp;spm_id_from=333.337.0.0">视频讲解1(推荐)</a><br>
<a href="https://www.bilibili.com/video/BV13J41157Wq?p=1">视频讲解2</a><br>
梯度下降：推所有，拉一个
<img loading="lazy" src="https://pic1.zhimg.com/80/v2-2b14281c6ed5afadae9d91e6bc864f58_720w.jpg" alt="梯度下降在最后一行 "  />
<br>
<a href="https://www.bilibili.com/video/BV13J41157Wq?p=4">梯度下降</a>就是通过数值法求导数然后更新x值的过程,在网络中的作用就是更新权重。<br>
学习率就是权重更新时候的学习率<br>
<img loading="lazy" src="https://zouheng22.gitee.io/images_-cabin/research/weight.jpg" alt="权重"  />
<br>
其他问题：<br>
<a href="https://www.jianshu.com/p/964345dddb70">为什么要用反向传播算法？</a></p>
<p>激活函数：<a href="https://zhuanlan.zhihu.com/p/105722023">softmax</a><br>
一般只作输出层的激活函数 
softmax函数一般与交叉熵函损失函数同时实现
激活函数的作用：激活函数可以让神经网络具有非线性拟合的能力<br>
激活函数既可以用在隐藏层(relu/tanh/sigmod)，也可以用在输出层(softmax/等值/sigmod)<br>
sigmod可以将任意输入映射至(0,1)<br>
<a href="https://zhuanlan.zhihu.com/p/32824193">激活函数</a>的作用是：增加模型的非线性表达能力</p>
<p>损失函数:</p>
<ul>
<li>
<p>MSE: 最小均方差</p>
</li>
<li>
<p>CE： 交叉熵</p>
</li>
<li>
<p>使用softmax实现分类</p>
<pre><code>//TODO

</code></pre></li>
</ul>
<p>张量(tensor)(一种数据结构)<br>
标量&ndash;&gt; 0阶张量<br>
向量&ndash;&gt; 1阶张量<br>
矩阵&ndash;&gt; 2阶张量</p>
</li>
<li></li>
</ul>
</li>
<li>
<p><a href="https://www.bilibili.com/video/BV1hE411t7RN?p=10">pytorch的使用</a></p>
</li>
</ol>
<p><a href="https://www.cnblogs.com/sdu20112013/p/12101172.html">https://www.cnblogs.com/sdu20112013/p/12101172.html</a></p>
<p>按分类的效果来说呢，隐藏层的单元数是越多越好的，但是过多的神经元会让训练相当的缓慢，因此需要平衡一下，一般将隐藏层的单元数设置为输入层单元数的2~4倍为宜。而隐藏层的层数呢就以1、2、3层比较常见。</p>
<p>多个全连接层+激活层 的作用 类似泰勒级数</p>
<p>Pytorch的交叉熵nn.CrossEntropyLoss在训练阶段，里面是内置了softmax操作的，因此只需要喂入原始的数据结果即可，不需要在之前再添加softmax层。</p>
<p>首先softmax不是损失函数,而是进行多分类时使用的激活函数。</p>
<p>学习率设置过大可能会导致，损失函数的值在极值点的附近震荡而不收敛。</p>
<p>激活函数：https://zhuanlan.zhihu.com/p/72462178</p>
<p>softmax层只是对神经网络的输出结果进行了一次换算，将输出结果用概率的形式表现出来。</p>
<p>如果要使用softmax 是不是不用在 网络层中显示添加？
<a href="https://zhuanlan.zhihu.com/p/105722023">https://zhuanlan.zhihu.com/p/105722023</a> 再看一遍</p>
<p>sigmod  与  softmax:<br>
简单点理解就是，Sigmoid函数，我们可以当作成它是对一个类别的“建模”，将该类别建模完成，另一个相对的类别就直接通过1减去得到。而softmax函数，是对两个类别建模，同样的，得到两个类别的概率之和是1。</p>
<p>softmax激活函数：<br>
<img loading="lazy" src="https://www.zhihu.com/equation?tex=Softmax%28z_%7Bi%7D%29%3D%5Cfrac%7Be%5E%7Bz_%7Bi%7D%7D%7D%7B%5Csum_%7Bc&#43;%3D&#43;1%7D%5E%7BC%7D%7Be%5E%7Bz_%7Bc%7D%7D%7D%7D" alt="softmax"  />
</p>
<p>交叉熵损失函数： 
<img loading="lazy" src="https://www.zhihu.com/equation?tex=L&#43;%3D&#43;%5Cfrac%7B1%7D%7BN%7D%5Csum_%7Bi%7D&#43;L_i&#43;%3D&#43;%5Cfrac%7B1%7D%7BN%7D%5Csum_%7Bi%7D-%5By_i%5Ccdot&#43;log%28p_i%29&#43;%2B&#43;%281-y_i%29%5Ccdot&#43;log%281-p_i%29%5D&#43;%5C%5C" alt="二分类"  />
</p>
<p><img loading="lazy" src="https://www.zhihu.com/equation?tex=L&#43;%3D&#43;-&#43;%5Csum_%7Bc&#43;%3D&#43;1%7D%5E%7BC%7D%7By_%7Bc%7D%5C&#43;log%28p_%7Bc%7D%29%7D" alt="交叉熵"  />
<br>
<img loading="lazy" src="https://www.zhihu.com/equation?tex=L&#43;%3D&#43;%5Cfrac%7B1%7D%7BN%7D%5Csum_%7Bi%7D&#43;L_i&#43;%3D&#43;-&#43;%5Cfrac%7B1%7D%7BN%7D%5Csum_%7Bi%7D&#43;%5Csum_%7Bc%3D1%7D%5EMy_%7Bic%7D%5Clog%28p_%7Bic%7D%29&#43;%5C%5C" alt="交叉熵"  />
</p>

</div>
  <footer class="post-footer">
    <ul class="post-tags">
      <li><a href="http://zouheng22.gitee.io/flippedzh/tags/yolo/">Yolo</a></li>
      <li><a href="http://zouheng22.gitee.io/flippedzh/tags/python/">python</a></li>
      <li><a href="http://zouheng22.gitee.io/flippedzh/tags/object-detection/">Object Detection</a></li>
    </ul>
<nav class="paginav">
  <a class="prev" href="http://zouheng22.gitee.io/flippedzh/posts/%E7%A0%94%E7%A9%B6%E7%94%9F/yolov3/">
    <span class="title">« Prev Page</span>
    <br>
    <span>yolov3原理与源码</span>
  </a>
  <a class="next" href="http://zouheng22.gitee.io/flippedzh/posts/yolov5%E5%B7%A5%E7%A8%8B%E7%BB%93%E6%9E%84%E8%AF%A6%E8%A7%A3/">
    <span class="title">Next Page »</span>
    <br>
    <span>yolov5工程结构详解</span>
  </a>
</nav>

<div class="share-buttons">
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on twitter"
        href="https://weibo.com/">
        <svg height="256px" style="enable-background:new 0 0 256 256;" version="1.1" viewBox="0 0 256 256" width="256px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="Background_1_" style="enable-background:new    ;">
        <g id="Background">
            <g>
                <path d="M249.422,30.68c-2.721-4.986-5.816-9.537-9.793-13.521     c-3.992-3.998-8.709-7.587-13.703-10.314c-8.381-4.576-18.788-6.855-29.002-6.855H59.075c-10.444,0-20.542,2.344-29.265,6.948     c-5.022,2.649-9.588,6.146-13.502,10.126c-3.932,3.998-7.491,8.488-10.046,13.572c-4.289,8.533-6.274,18.478-6.274,28.65v137.43     c0,10.326,1.671,20.678,6.296,29.134c2.681,4.9,6.191,9.86,10.087,13.795c3.934,3.97,8.583,7.225,13.503,9.955     c8.465,4.7,18.842,6.413,29.201,6.413h137.849c10.568,0,20.399-1.523,28.982-6.401c4.739-2.692,9.879-6.113,13.687-9.966     c3.923-3.968,7.2-8.851,9.886-13.799c4.566-8.415,6.533-18.874,6.533-29.131V59.285C256.012,48.978,254.031,39.124,249.422,30.68     z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#FFE591;"/>
            </g>
        </g>
    </g>
        <g id="Shape_4_1_" style="enable-background:new    ;">
            <g id="Shape_4">
                <g>
                <path d="M169.217,151.074c-2.088-20.866-29.861-35.239-62.04-32.095     c-32.171,3.145-56.568,22.611-54.478,43.479c2.09,20.876,29.865,35.248,62.039,32.11     C146.916,191.425,171.303,171.957,169.217,151.074z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;"/>
            </g></g>
        </g><g id="Shape_3_1_" style="enable-background:new    ;">
            <g id="Shape_3"><g><path d="M179.092,125.276c-2.738-0.812-4.615-1.361-3.18-4.917     c3.104-7.715,3.425-14.372,0.059-19.121c-6.311-8.908-23.572-8.427-43.359-0.239c0-0.011-6.212,2.687-4.625-2.184     c3.044-9.67,2.585-17.771-2.151-22.444c-10.736-10.616-39.284,0.399-63.764,24.585c-18.333,18.12-28.979,37.325-28.979,53.928     c0,31.76,41.215,51.07,81.536,51.07c52.858,0,88.019-30.345,88.019-54.443C202.648,136.952,190.239,128.692,179.092,125.276z      M114.738,194.569c-32.174,3.138-59.949-11.234-62.039-32.11c-2.09-20.868,22.307-40.335,54.478-43.479     c32.179-3.145,59.952,11.229,62.04,32.095C171.303,171.957,146.916,191.425,114.738,194.569z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#CD201F;"/></g></g></g><g id="Shape_2_1_" style="enable-background:new    ;"><g id="Shape_2"><g><path d="M117.572,134.441c-15.319-3.905-32.636,3.573-39.29,16.802     c-6.777,13.483-0.225,28.456,15.254,33.354c16.032,5.063,34.93-2.701,41.5-17.255     C141.516,153.107,133.426,138.454,117.572,134.441z M105.874,168.889c-3.115,4.863-9.783,6.996-14.806,4.749     c-4.949-2.204-6.411-7.861-3.296-12.604c3.076-4.729,9.52-6.834,14.505-4.785C107.321,158.354,108.931,163.969,105.874,168.889z      M116.131,155.985c-1.125,1.887-3.615,2.794-5.565,2.007c-1.917-0.772-2.518-2.878-1.429-4.735     c1.122-1.844,3.513-2.744,5.427-1.999C116.508,151.952,117.206,154.086,116.131,155.985z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#232323;"/></g></g></g><g id="Shape_1_1_" style="enable-background:new    ;"><g id="Shape_1"><g><path d="M212.111,67.308c-12.48-14.403-30.891-19.894-47.882-16.133     h-0.007c-3.932,0.876-6.438,4.901-5.598,8.986c0.839,4.089,4.706,6.701,8.639,5.829c12.088-2.672,25.168,1.236,34.043,11.467     c8.863,10.23,11.271,24.185,7.475,36.416l0.002,0.004c-1.236,3.986,0.856,8.247,4.689,9.535c3.817,1.288,7.922-0.891,9.16-4.864     c0-0.008,0-0.022,0.003-0.03C227.965,101.311,224.595,81.696,212.111,67.308z M169.621,77.464     c-3.383,0.751-5.54,4.218-4.815,7.743c0.726,3.51,4.052,5.767,7.429,5.001v0.007c4.048-0.89,8.436,0.409,11.404,3.831     c2.975,3.43,3.773,8.104,2.497,12.203h0.007c-1.061,3.422,0.738,7.103,4.03,8.214c3.292,1.097,6.823-0.773,7.884-4.203     c2.603-8.383,0.977-17.936-5.111-24.95C186.871,78.296,177.901,75.632,169.621,77.464z" style="fill-rule:evenodd;clip-rule:evenodd;fill:#DD880C;"/></g></g></g></svg>
    </a>
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on linkedin"
        href="https://www.linkedin.com/shareArticle?mini=true&amp;url=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f&amp;title=yolov5%e5%8e%9f%e7%90%86%e4%b8%8e%e6%ba%90%e7%a0%81&amp;summary=yolov5%e5%8e%9f%e7%90%86%e4%b8%8e%e6%ba%90%e7%a0%81&amp;source=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f">
    
        <svg id="douyin" t="1570181112474" class="icon" viewBox="0 0 1024 1024" version="1.1"
          xmlns="http://www.w3.org/2000/svg" p-id="2916" width="128" height="128">
          <path
            d="M937.386667 423.850667a387.84 387.84 0 0 1-232.874667-77.824v352.341333C704.512 878.250667 565.930667 1024 394.922667 1024S85.333333 878.250667 85.333333 698.368c0-179.882667 138.581333-325.632 309.589334-325.632 17.066667 0 33.706667 1.450667 49.92 4.266667v186.624a131.754667 131.754667 0 0 0-48.64-9.216c-76.288 0-138.154667 65.024-138.154667 145.322666 0 80.213333 61.866667 145.322667 138.24 145.322667 76.202667 0 138.069333-65.109333 138.069333-145.322667V0h172.714667c0 134.485333 103.68 243.541333 231.594667 243.541333v180.309334h-1.28"
            p-id="2917"></path>
        </svg>

    </a>
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on reddit"
        href="https://www.linkedin.com/shareArticle?mini=true&amp;url=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f&amp;title=yolov5%e5%8e%9f%e7%90%86%e4%b8%8e%e6%ba%90%e7%a0%81&amp;summary=yolov5%e5%8e%9f%e7%90%86%e4%b8%8e%e6%ba%90%e7%a0%81&amp;source=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f">
        <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="m437 0h-362c-41.398438 0-75 34.601562-75 76v361c0 41.398438 33.601562 75 75 75h362c41.398438 0 75-33.601562 75-75v-361c0-41.398438-33.601562-76-75-76zm0 0" fill="#25d9f8"/><path d="m512 76v361c0 41.398438-33.601562 75-75 75h-181v-512h181c41.398438 0 75 34.601562 75 76zm0 0" fill="#00c0f1"/><g fill="#ececf1"><path d="m121 196h60v211h-60zm0 0"/><path d="m121 106h60v60h-60zm0 0"/><path d="m391 275.800781v131.199219h-60v-121c0-16.5-13.5-30-30-30s-30 13.5-30 30v121h-60v-211h60v11.398438c15.601562-5.097657 25.800781-11.398438 45-11.398438 40.800781 0 75 36.597656 75 79.800781zm0 0"/></g><path d="m391 275.800781v131.199219h-60v-121c0-16.5-13.5-30-30-30s-30 13.5-30 30v121h-15v-211h15v11.398438c15.601562-5.097657 25.800781-11.398438 45-11.398438 40.800781 0 75 36.597656 75 79.800781zm0 0" fill="#e2e2e7"/></svg>
    </a>
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on facebook"
        href="https://facebook.com/sharer/sharer.php?u=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f">
        <svg version="1.1" viewBox="0 0 512 512" xml:space="preserve">
            <path
                d="M449.446,0c34.525,0 62.554,28.03 62.554,62.554l0,386.892c0,34.524 -28.03,62.554 -62.554,62.554l-106.468,0l0,-192.915l66.6,0l12.672,-82.621l-79.272,0l0,-53.617c0,-22.603 11.073,-44.636 46.58,-44.636l36.042,0l0,-70.34c0,0 -32.71,-5.582 -63.982,-5.582c-65.288,0 -107.96,39.569 -107.96,111.204l0,62.971l-72.573,0l0,82.621l72.573,0l0,192.915l-191.104,0c-34.524,0 -62.554,-28.03 -62.554,-62.554l0,-386.892c0,-34.524 28.029,-62.554 62.554,-62.554l386.892,0Z" />
        </svg>
    </a>
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on whatsapp"
        href="https://weixin.qq.com/">
        <svg height="512pt" viewBox="0 -45 512 512" width="512pt" xmlns="http://www.w3.org/2000/svg"><path d="m138.667969 96h-21.335938v21.332031h21.335938zm0 0"/><path d="m245.332031 96h-21.332031v21.332031h21.332031zm0 0"/><path d="m320 224h-21.332031v21.332031h21.332031zm0 0"/><path d="m426.667969 224h-21.335938v21.332031h21.335938zm0 0"/><path d="m469.332031 422.535156-65.730469-32.800781c-13.398437 3.269531-27.140624 4.925781-40.933593 4.933594-82.402344 0-149.335938-57.46875-149.335938-128 0-70.535157 66.933594-128 149.335938-128 82.398437 0 149.332031 57.464843 149.332031 128 0 33.867187-15.066406 65.464843-42.667969 89.464843zm-63.332031-55.46875 42 21.066406v-42l4-3.199218c24.933594-20.265625 38.667969-47.332032 38.667969-76.265625 0-58.800781-57.46875-106.667969-128-106.667969-70.535157 0-128 47.867188-128 106.667969 0 58.796875 57.464843 106.664062 128 106.664062 13.324219.019531 26.597656-1.730469 39.464843-5.199219zm0 0"/><path d="m64 326.535156v-63.335937c-40.800781-28.53125-64-69.734375-64-113.867188 0-82.398437 81.332031-149.332031 181.332031-149.332031s181.335938 66.933594 181.335938 149.332031l-21.335938.402344v-.402344c0-70.53125-71.730469-128-160-128-88.265625 0-160 57.46875-160 128 0 38.535157 21.601563 74.667969 59.203125 99.203125l4.796875 3.199219v40.398437l43.601563-21.734374 3.867187.933593c29.613281 7.433594 60.539063 7.980469 90.398438 1.601563l4.535156 20.800781c-31.761719 6.785156-64.625 6.511719-96.269531-.800781zm0 0"/></svg>
    </a>
    <a target="_blank" rel="noopener noreferrer" aria-label="share yolov5原理与源码 on telegram"
        href="https://telegram.me/share/url?text=yolov5%e5%8e%9f%e7%90%86%e4%b8%8e%e6%ba%90%e7%a0%81&amp;url=http%3a%2f%2fzouheng22.gitee.io%2fflippedzh%2fposts%2fyolov5%25E5%258E%259F%25E7%2590%2586%25E4%25B8%258E%25E6%25BA%2590%25E7%25A0%2581%2f">
        <svg version="1.1" xml:space="preserve" viewBox="2 2 28 28">
            <path
                d="M26.49,29.86H5.5a3.37,3.37,0,0,1-2.47-1,3.35,3.35,0,0,1-1-2.47V5.48A3.36,3.36,0,0,1,3,3,3.37,3.37,0,0,1,5.5,2h21A3.38,3.38,0,0,1,29,3a3.36,3.36,0,0,1,1,2.46V26.37a3.35,3.35,0,0,1-1,2.47A3.38,3.38,0,0,1,26.49,29.86Zm-5.38-6.71a.79.79,0,0,0,.85-.66L24.73,9.24a.55.55,0,0,0-.18-.46.62.62,0,0,0-.41-.17q-.08,0-16.53,6.11a.59.59,0,0,0-.41.59.57.57,0,0,0,.43.52l4,1.24,1.61,4.83a.62.62,0,0,0,.63.43.56.56,0,0,0,.4-.17L16.54,20l4.09,3A.9.9,0,0,0,21.11,23.15ZM13.8,20.71l-1.21-4q8.72-5.55,8.78-5.55c.15,0,.23,0,.23.16a.18.18,0,0,1,0,.06s-2.51,2.3-7.52,6.8Z" />
        </svg>
    </a>
</div>

  </footer>
</article>
    </main>
    <footer class="footer">
    <span>&copy; 2022 <a href="http://zouheng22.gitee.io/flippedzh">flipped</a></span>
    <span>
        Powered by
        <a href="https://gohugo.io/" rel="noopener noreferrer" target="_blank">Hugo</a> &
        <a href="https://git.io/hugopapermod" rel="noopener" target="_blank">PaperMod</a>
    </span>
</footer>
<a href="#top" aria-label="go to top" title="Go to Top (Alt + G)">
    <button class="top-link" id="top-link" type="button" accesskey="g">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentColor">
            <path d="M12 6H0l6-6z" />
        </svg>
    </button>
</a>

<script>
    let menu = document.getElementById('menu')
    menu.scrollLeft = localStorage.getItem("menu-scroll-position");
    menu.onscroll = function () {
        localStorage.setItem("menu-scroll-position", menu.scrollLeft);
    }

    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener("click", function (e) {
            e.preventDefault();
            var id = this.getAttribute("href").substr(1);
            if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
                document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
                    behavior: "smooth"
                });
            } else {
                document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
            }
            if (id === "top") {
                history.replaceState(null, null, " ");
            } else {
                history.pushState(null, null, `#${id}`);
            }
        });
    });

</script>
<script>
    var mybutton = document.getElementById("top-link");
    window.onscroll = function () {
        if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
            mybutton.style.visibility = "visible";
            mybutton.style.opacity = "1";
        } else {
            mybutton.style.visibility = "hidden";
            mybutton.style.opacity = "0";
        }
    };

</script>
<script>
    document.getElementById("theme-toggle").addEventListener("click", () => {
        if (document.body.className.includes("dark")) {
            document.body.classList.remove('dark');
            localStorage.setItem("pref-theme", 'light');
        } else {
            document.body.classList.add('dark');
            localStorage.setItem("pref-theme", 'dark');
        }
    })

</script>
<script>
    document.querySelectorAll('pre > code').forEach((codeblock) => {
        const container = codeblock.parentNode.parentNode;

        const copybutton = document.createElement('button');
        copybutton.classList.add('copy-code');
        copybutton.innerText = 'copy';

        function copyingDone() {
            copybutton.innerText = 'copied!';
            setTimeout(() => {
                copybutton.innerText = 'copy';
            }, 2000);
        }

        copybutton.addEventListener('click', (cb) => {
            if ('clipboard' in navigator) {
                navigator.clipboard.writeText(codeblock.textContent);
                copyingDone();
                return;
            }

            const range = document.createRange();
            range.selectNodeContents(codeblock);
            const selection = window.getSelection();
            selection.removeAllRanges();
            selection.addRange(range);
            try {
                document.execCommand('copy');
                copyingDone();
            } catch (e) { };
            selection.removeRange(range);
        });

        if (container.classList.contains("highlight")) {
            container.appendChild(copybutton);
        } else if (container.parentNode.firstChild == container) {
            
        } else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
            
            codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
        } else {
            
            codeblock.parentNode.appendChild(copybutton);
        }
    });
</script>
</body>

</html>
